﻿@{
    WebSecurity.RequireAuthenticatedUser();
    this.Init(layout: "~/_SiteLayout.cshtml", title: "Change Password", action:Account.ChangePassword.Init);
}

<form method="post" action="">
    <fieldset>
        <legend>Change Password Form</legend>
        <p>
            Use this form to change your password. You'll be required to enter your current password. 
            Click <a href="@Href("~/Account/ForgotPassword")" title="Forgot password page">here</a> if you've forgotten your password.
        </p>
        @*we have submitted a postback and password changed successfully*@
        @if (Page.Success)
        {
            <p class="message success">
                Your password has been updated!
            </p>
        }
        else if(!Page.IsValid)
        {
            <p class="message error">
                @(Page.Errors.Provider.Message ?? "Password change failed. Please correct the errors and try again.");
            </p>
        }        
        <ol>
            <li class="current-password">                
                <label for="currentPassword">Current Password:</label>
                <input type="password" id="currentPassword" name="currentPassword" title="Current password" @if(Page.Errors.CurrentPassword.IsError){<text>class="error-field"</text>} />
                @if (Page.Errors.CurrentPassword.IsError) {
                    <label for="currentPassword" class="validation-error">@Page.Errors.CurrentPassword.Message</label>
                }
            </li>
            <li class="new-password">            
                <label for="newPassword">New Password:</label> 
                <input type="password" id="newPassword" name="newPassword" title="New password" @if(Page.Errors.NewPassword.IsError){<text>class="error-field"</text>} />
                @if (Page.Errors.NewPassword.IsError) {
                    <label for="newPassword" class="validation-error">@Page.Errors.NewPassword.Message</label>
                }
            </li>
            <li class="confirm-password">
                <label for="confirmPassword">Confirm Password:</label> 
                <input type="password" id="confirmPassword" name="confirmPassword" title="Confirm new password" @if(Page.Errors.ConfirmPassword.IsError){<text>class="error-field"</text>} />
                @if (Page.Errors.ConfirmPassword.IsError) {
                    <label for="confirmPassword" class="validation-error">@Page.Errors.ConfirmPassword.Message</label>
                }                
            </li>
        </ol>
        <p class="form-actions">
            <input type="submit" value="Change Password" title="Change password" />
        </p>
    </fieldset>
</form>